﻿using FoodModel;
using J.FoodManageGet.Application.Command.GroupingCommand;
using J.FoodRepository.InterFace;
using MediatR;
using SqlSugar;

namespace J.FoodManageGet.Application.CommandHandler.GroupingCommandHandler
{
    public class GroupingShowCommandHandler : IRequestHandler<GroupingShowCommand, List<GroupingModel>>
    {
        private readonly IGroupingRepository _groupingRepository;

        public GroupingShowCommandHandler(IGroupingRepository groupingRepository)
        {
            _groupingRepository = groupingRepository;
        }
        public async Task<List<GroupingModel>> Handle(GroupingShowCommand request, CancellationToken cancellationToken)
        {
            var list= await _groupingRepository.GroupingShow();
            var list1 = list.OrderByDescending(x => x.GroupingId);
            return list1.ToList();
        }
    }
}
